package com.joven.shelltest.enums;

import cn.hutool.core.util.EnumUtil;

/**
 * 枚举调用 Optional
 * @Author wzj
 * @Date 2023-11-08 08:55
 **/
public class EnumTest {
    public static void main(String[] args) {

//        System.out.println(FluxTypeEnum.WE_CHAT.getType());
//        System.out.println(FluxTypeEnum.WEI_BO.getName());
//        System.out.println(FluxTypeEnum.WE_CHAT.getDesc());
//        System.out.println(FluxTypeEnum.getNameByType("7"));
//
//        Optional<FluxTypeEnum> optional =  Optional.ofNullable(FluxTypeEnum.getFluxType("9"));
//        optional.ifPresent(fluxTypeEnum -> System.out.println(fluxTypeEnum.getDesc()));
//
//        Arrays.stream(FluxTypeEnum.COMMON_TYPE).forEach(System.out::println);
//        System.out.println(FluxTypeEnum.RED_BOOK.link().getName());


//        EnumSet<FluxTypeEnum> set = EnumSet.range(FluxTypeEnum.WE_CHAT, FluxTypeEnum.KNOWN);
//        for (FluxTypeEnum season : set) {
//            System.out.println(season);
//        }

//        EnumSet<FluxTypeEnum> set1 = EnumSet.range(FluxTypeEnum.WE_CHAT, FluxTypeEnum.WEI_BO);
//        for (FluxTypeEnum season : set1) {
//            System.out.println(season);
//        }
//
//        SingleEnum singleEnum = SingleEnum.INSTANCE;
//        System.out.println(singleEnum.doSomething("test"));


//        List<String> names = EnumUtil.getNames(ServiceExceptionEnum.class);
//        List<String> fieldNames = EnumUtil.getFieldNames(ServiceExceptionEnum.class);
//        List<Object> fieldValues = EnumUtil.getFieldValues(ServiceExceptionEnum.class,"message");
//        fieldValues.forEach(System.out::println);

        String type = EnumUtil.getFieldBy(ServiceExceptionEnum::getMessage, Enum::name, "MISSING_REQUEST_PARAM_ERROR");
        String type1 = EnumUtil.getFieldBy(ServiceExceptionEnum::getMessage, Enum::ordinal, 3);
        System.out.println(type);
//        String name =EnumUtil.getName(ServiceExceptionEnum.SUCCESS);
//        String fieldValue = EnumUtil.getFieldValue(ServiceExceptionEnum.INVALID_REQUEST_PARAM_ERROR,"message");
    }
}
